/*
 * @Descripttion: 系统用户Api
 * @version: 1.0
 * @Author: ddl
 * @Date: 2021-07-01 14:03:28
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-08-05 21:11:05
 */
import axios from '@/libs/api.request'
import config from '@/config'
// import store from '@/store'
import qs from 'qs'

// 系统用户 -> 登录
export const userLogin = (data) => {
  return axios.request({
    url: `${config.baseUrl.authServer}oauth/token`,
    data: qs.stringify(data),
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded',
      'Authorization': 'Basic dXNlci1zZXJ2aWNlOjEyMzQ1Ng=='
    },
    hideErrorTip: true,
    notAuth: true
  })
}

// 系统用户 -> 获取用户信息
export const userInfo = (data) => {
  // let userLogin = JSON.parse(sessionStorage.getItem('userLogin'))
  // console.log(userLogin)
  // console.log(store.getters)
  return axios.request({
    url: `${config.baseUrl.userServer}securityuser/authorityInfo`,
    data: qs.stringify(data),
    method: 'post',
    headers: {
      // 'Content-Type': 'application/x-www-form-urlencoded',
      // 'Authorization': `bearer ${userLogin.access_token}`
    },
    hideErrorTip: true
  })
}

// 系统用户 -> 获取用户权限
export const userAuth = (data) => {
  return axios.request({
    url: `${config.baseUrl.userServer}securityuser/info`,
    data: qs.stringify(data),
    method: 'post',
    headers: {
      // 'Content-Type': 'application/x-www-form-urlencoded',
      // 'Authorization': 'Basic dXNlci1zZXJ2aWNlOjEyMzQ1Ng=='
    }
  })
}

// 系统用户 -> JAE登录/获取用户信息
export const userJAELogin = (data) => {
  return axios.request({
    url: `${config.baseUrl.server}msa/api.jsp/sys/os/user\0`,
    data: data,
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
    },
    hideErrorTip: true,
    notAuth: true
  })
}
